package com.example.readbook.Sql;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Package    : com.example.readbook.Sql
 * ClassName  : Sqlite
 * Description: $数据库建表类
 * Date       : 2019/3/22 11:46
 */
public class Sqlite extends SQLiteOpenHelper {
    //书架表
    private static final String table = "CREATE TABLE IF NOT EXISTS book(" +
            "id integer primary key autoincrement," +
            "name text,"  + "color text," + "address text," + "size text" + ")";

    //读后感表
    private static final String journalEntry = "create table if not exists journal("
            + "id integer primary key autoincrement," + "name text," + "entry text," + "time text" + ")";

    public Sqlite(Context context) {
        super(context, "book.db", null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(table);
        db.execSQL(journalEntry);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
